function add0(num) {
  if (num < 10) {
    return '0' + num;
  } else {
    return num;
  }
}


function getTime() {
  let now = new Date();
  let month = now.getMonth() + 1;
  let day = now.getDate();
  let hours = now.getHours();
  let minutes = now.getMinutes();
  let seconds = now.getSeconds();
  return [
    add0(month) + '月' + add0(day) + '日',
    add0(hours) + ':' + add0(minutes) + ':' + add0(seconds)
  ]
}


window.onload = () => {
  const dateDom = document.getElementById('date');
  const timeDom = document.getElementById('time');
  setInterval(() => {
    let [date, time] = getTime();
    dateDom.innerHTML = date;
    timeDom.innerHTML = time;
  }, 1000)
}